﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/

 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license

 This code is provided on an AS IS basis, with no WARRANTIES,
  CONDITIONS or GUARANTEES of any kind.
-->
<UserControl x:Class="Peter.View.ViewFileExplorer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:logic="clr-namespace:Peter.Logic"
             xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:mvvm="clr-namespace:Peter.Common.Tree;assembly=Peter.Common"
             xmlns:common="clr-namespace:Peter.Common;assembly=Peter.Common"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300"
             Background="{DynamicResource BackgroundBrush}"
             d:DataContext="{d:DesignInstance logic:ModelFileExplorer}">
   <Grid>
      <controls:Explorer ExecuteCommand="{Binding Path=ExecuteCommand}"
                         SelectedPath="{Binding Path=SelectedFilePath, Mode=TwoWay}"
                         SelectedTreeItem="{Binding Path=SelectedItem, Mode=TwoWay}"
                         FileSystem="{Binding Path=FileSystem, Mode=OneWayToSource}">
         <controls:Explorer.ContextMenu>
            <ContextMenu>
               <MenuItem Header="Edit in Peter"
                         Command="{Binding Path=ExecuteCommand}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Edit" />
                  </MenuItem.Icon>
               </MenuItem>
               <MenuItem Header="Open via Windows"
                         Command="{Binding Path=RunProcessCommand}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Opennewwindow" />
                  </MenuItem.Icon>
               </MenuItem>
               <Separator />
               <MenuItem Header="Create File"
                         Command="{Binding Path=CreateFileCommand}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Createfile" />
                  </MenuItem.Icon>
               </MenuItem>
               <MenuItem Header="Create Folder"
                         Command="{Binding Path=CreateFolderCommand}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Createfolder" />
                  </MenuItem.Icon>
               </MenuItem>
               <MenuItem Header="Rename"
                         Command="{Binding Path=RenameCommand}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Textfield" />
                  </MenuItem.Icon>
               </MenuItem>
               <Separator />
               <MenuItem Header="Cut"
                         Command="{Binding Path=EditCommand}"
                         CommandParameter="{x:Static common:EditAction.Cut}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="CutScissors" />
                  </MenuItem.Icon>
               </MenuItem>
               <MenuItem Header="Copy"
                         Command="{Binding Path=EditCommand}"
                         CommandParameter="{x:Static common:EditAction.Copy}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Copy" />
                  </MenuItem.Icon>
               </MenuItem>
               <MenuItem Header="Paste"
                         Command="{Binding Path=EditCommand}"
                         CommandParameter="{x:Static common:EditAction.Paste}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="ClipboardPaste" />
                  </MenuItem.Icon>
               </MenuItem>
               <MenuItem Header="Delete"
                         Command="{Binding Path=EditCommand}"
                         CommandParameter="{x:Static common:EditAction.Delete}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Remove" />
                  </MenuItem.Icon>
               </MenuItem>
               <Separator />
               <MenuItem Header="Properties"
                         Command="{Binding Path=PropertiesCommand}">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Reliability" />
                  </MenuItem.Icon>
               </MenuItem>
            </ContextMenu>
         </controls:Explorer.ContextMenu>

         <controls:Explorer.Resources>

            <DataTemplate DataType="{x:Type mvvm:ModelTreeViewItem}">
               <StackPanel Orientation="Horizontal"
                           VerticalAlignment="Center">
                  <icons:IconDisplay IconSize="MediumLarge"
                                     Margin="0,0,3,0"
                                     Icon="{Binding Path=Icon}"
                                     Foreground="{Binding Path=IconBrush}" />
                  <TextBlock Text="{Binding Path=Text}"
                             VerticalAlignment="Center"
                             Margin="0, 0, 5, 0" />
               </StackPanel>
            </DataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type controls:ExplorerItem}"
                                      ItemsSource="{Binding Path=Children}">
               <StackPanel Orientation="Horizontal"
                           VerticalAlignment="Center">
                  <Border BorderBrush="{Binding Path=BorderBrush}"
                          BorderThickness="{Binding Path=BorderThickness}"
                          Margin="{Binding Path=IconMargin}"
                          Padding="{Binding Path=IconPadding}">
                     <icons:IconDisplay IconSize="{Binding Path=IconSize}"
                                        Icon="{Binding Path=Icon}"
                                        x:Name="IconDisplay"
                                        Foreground="{Binding Path=IconBrush}" />
                  </Border>
                  <TextBlock Text="{Binding Path=Text}"
                             VerticalAlignment="Center"
                             Margin="0, 0, 5, 0"
                             Opacity="{Binding Path=IconBrush.Opacity}"/>
               </StackPanel>
            </HierarchicalDataTemplate>

         </controls:Explorer.Resources>
      </controls:Explorer>
   </Grid>
</UserControl>
